Repository navigation
feat(stellar): fetch policy observability - #642
Julink-eth wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the Stellar fetch-policy observability changes.
No open issues 🎉
What changed in this PR
This PR connects the Stellar snap to the shared fetch-policy observability introduced in #566, following Solana’s adoption in #583.
Changes:
- Adds shared analytics and sanitized Sentry reporting for Stellar RPC, Price, Token, and Security Alerts policies; Horizon receives analytics only to avoid duplicate Sentry reports.
- Prevents reporting errors already handled by fetch policies and user-rejected requests.
- Adds reporting-wiring and error-filter tests, updates coverage thresholds, and documents the behavior.
| File | Description |
|---|---|
packages/stellar-wallet-snap/vitest.config.ts |
Slightly raises coverage thresholds. |
packages/stellar-wallet-snap/src/utils/errors.ts |
Filters already-reported policy errors and user rejections. |
packages/stellar-wallet-snap/src/utils/errors.test.ts |
Tests error-reporting filters and ordinary error reporting. |
packages/stellar-wallet-snap/src/utils/analytics.ts |
Centralizes analytics and fetch-policy reporting options. |
packages/stellar-wallet-snap/src/services/price/price-api/PriceApiClient.ts |
Enables Price API policy reporting. |
packages/stellar-wallet-snap/src/services/price/price-api/PriceApiClient.test.ts |
Verifies Price API reporting configuration. |
packages/stellar-wallet-snap/src/services/network/NetworkService.ts |
Enables Horizon analytics and RPC analytics/Sentry reporting. |
packages/stellar-wallet-snap/src/services/network/NetworkService.test.ts |
Verifies distinct Horizon and RPC reporting configurations. |
packages/stellar-wallet-snap/src/services/asset-metadata/token-api/TokenApiClient.ts |
Enables Token API policy reporting. |
packages/stellar-wallet-snap/src/services/asset-metadata/token-api/TokenApiClient.test.ts |
Verifies Token API reporting configuration. |
packages/stellar-wallet-snap/src/context.ts |
Reuses shared analytics and enables Security Alerts policy reporting. |
packages/stellar-wallet-snap/snap.manifest.json |
Updates the bundle checksum. |
packages/stellar-wallet-snap/CHANGELOG.md |
Documents observability behavior and Horizon’s reporting exception. |
Review effort: Balanced
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
| this.#policy = createFetchPolicy({ | ||
| service: 'price_api', | ||
| logger: _logger, | ||
| ...fetchPolicyReporting, |
There was a problem hiding this comment.
im wondering why we dont move those api client into the share utils first, as they should be the same
There was a problem hiding this comment.
They could, but the problem today is that they differ (Bitcoin is on /v1 with a different response; Solana and Tron add caching and chunking; Stellar doesn't). Moving them is a refactor across 4 snaps so we could do it but it's a PR own its own imo not related to this one.
| getSnapProvider, | ||
| logError: logger.error.bind(logger), | ||
| shouldTrack: (error) => | ||
| !(error instanceof UserRejectedRequestError) && |
There was a problem hiding this comment.
there is a default shouldTrack from the utils ? no ?
There was a problem hiding this comment.
Good catch, a small change is needed in the utils package though (add isReportedFetchPolicyError to defaultShouldTrack) but it's small so I'll do it in this PR.
|



Explanation
Wires the Stellar snap into the fetch policy observability added in #566, as Solana (#583) and Tron already do.
analyticsandtrackError, through a newutils/analytics.ts. Outages send "Snap Service Degraded" and "Snap Service Unavailable" to Segment, and calls that use up their retries are reported to Sentry once, sanitised.trackErrorskips errors a policy already reported (isReportedFetchPolicyError), so callers don't report them again. Every Stellar wrapper keeps the policy error ascause, so the check works through them.analytics, with notrackError.Why Horizon has no
trackErrorThe Horizon policy runs inside the Stellar SDK as its HTTP adapter. For reads (
loadAccount,fetchBaseFee,transactions()), the SDK catches the policy error and rethrows a newNetworkError,NotFoundErroror plainError, withoutcause(CallBuilder._handleNetworkError). Callers can't recognise these as already reported, so giving the policytrackErrorwould send every Horizon give-up to Sentry twice. Restoring the link would mean patching SDK internals.So Horizon gets the Segment events, and its Sentry reporting stays as today: callers report the SDK's error. The known cost is that Horizon open-circuit errors keep reaching Sentry once per blocked call, as they do now.
Stellar RPC doesn't have this problem: the SDK passes its errors through unchanged.
createTrackError's default shouldTrack now also skips errors a fetch policy already reported, so Stellar, Solana and Tron drop their identical override (no behaviour change).References
Checklist